uniform extern texture ScreenTexture;	

sampler ScreenS = sampler_state
{
	Texture = <ScreenTexture>;	
};

float2 gScreenSize = float2(800, 480);
float2 gCenter = float2(400, 240);	// Center of the effect
float gInnerRadius = 20.0f;				// Inner radius of visibility
float gOuterRadius = 40.0f;				// Outer radiuc of visibility
float gSolidWidth = 0.3f;				// Width of most opaque area
float gAlpha = 1.0f;	// Color of effect, Alpha is the alpha of most opaque area.

float cClamp(float v, float min, float max)
{
	float r = v < min ? min : (v > max ? max : v);
	return r;
}

float4 PixelShaderFunction(float2 texCoord: TEXCOORD0) : COLOR0
{
    float2 delta = gCenter - texCoord * gScreenSize;

	float halfWidth = (gOuterRadius - gInnerRadius) / 2.0f;
	float center = gInnerRadius + halfWidth;
	float gradientPos = abs(center - length(delta));

	float solidWidth = halfWidth * gSolidWidth;
	float transparency = cClamp((gradientPos - solidWidth) / (halfWidth - solidWidth), 0.0f, 1.0f);
	return float4(1,1,1, gAlpha * (1.0f - transparency));
}

technique Shockwave
{
	pass Pass1
	{
		PixelShader = compile ps_2_0 PixelShaderFunction();
	}
}
